package com.easyjava.qingke.project.command.impl;

import com.easyjava.qingke.project.command.SystemCommand;
import com.easyjava.qingke.project.mybatis.pojo.PurchasePlanning;
import com.easyjava.qingke.project.util.ProjectConsole;

public class JudgeCommand extends SystemCommand {

	public void excute() {
		
		dao.getPurchasePlanningByStatus();
		ProjectConsole.println();
		
		int id =ProjectConsole.promptInt("请输入需要审批的ID：");
		while(id>0){
			if(!dao.isPurchasePlanningIdExists(id)){
				ProjectConsole.println("该ID不存在！");
				id=ProjectConsole.promptInt("请重新输入需要审批的ID：");
			}
			judgePurchasePlanning(id);
			
			int number=ProjectConsole.promptInt("输入1表示继续审批，2表示退出。");
			if(1==number){
				id =ProjectConsole.promptInt("请输入需要审批的ID：");
			}else if(2==number){
				break;
			}
		}
		
	}
	
	public void judgePurchasePlanning(int id ){
		PurchasePlanning purchasePlanning=new PurchasePlanning();
		purchasePlanning.setId(id);
		
		String status=ProjectConsole.prompt("请输入通过或拒绝：");
		purchasePlanning.setStatus(status);
		
		dao.changePurchasePlanning(purchasePlanning);
	}

}
